package com.ubxtech.xxljob.service;

import com.ubxtech.core.req.PageReq;
import com.ubxtech.xxljob.bo.JobGroupPage;
import com.ubxtech.xxljob.bo.JobInfoPage;
import com.ubxtech.xxljob.bo.XxlGroupInfo;
import com.ubxtech.xxljob.bo.XxlJobInfo;
import com.ubxtech.xxljob.req.*;

import java.util.Collection;
import java.util.List;

/**
 * 封装xxl admin 接口
 * @author Victor.Xiao
 * @since 2022-11-17 17:49
*/
public interface XxlJobService {


    /**
     * 任务列表
     * @author Victor.Xiao
     * @since 2022-11-18 17:53
     * @param pageReq pageReq
     * @return com.ubxtech.xxljob.bo.JobInfoPage
    */
    JobInfoPage jobPageList(PageReq<XxlJobPageReq> pageReq);

    /**
     * 执行器列表
     * @author Victor.Xiao
     * @since 2022-11-18 19:21
     * @param pageReq pageReq
     * @return com.ubxtech.xxljob.bo.JobGroupPage
    */
    JobGroupPage jobGroupPageList(PageReq<XxlJobGroupPageReq> pageReq);

    /**
     * 包含添加job的所有参数
     * @author Victor.Xiao
     * @since 2022-11-17 17:50
     * @param jobInfo 任务信息
     * @return java.lang.Integer 任务id
    */
    Integer add(XxlJobInfo jobInfo);

    /**
     * 添加job
     * @author Victor.Xiao
     * @since 2022-11-17 19:39
     * @param xxlJobAddReq xxlJobAddReq
     * @return java.lang.Integer
    */
    Integer add(XxlJobAddReq xxlJobAddReq);


    /**
     * 批量添加job
     * @author Victor.Xiao
     * @since 2022-11-22 17:32
     * @param xxlJobAddReq xxlJobAddReq
     * @param batchAddDiffInfo batchAddDiffInfo
     * @return java.util.List<java.lang.Integer>
     */
    List<Integer> addBatch(XxlJobAddReq xxlJobAddReq,List<XxlJobBatchAddDiffInfoReq> batchAddDiffInfo);
    /**
     * update job
     * @author Victor.Xiao
     * @since 2022-11-17 19:40
     * @param xxlJobUpdateReq xxlJobUpdateReq
    */
    void update(XxlJobUpdateReq xxlJobUpdateReq);
    /**
     * update job
     * @author Victor.Xiao
     * @since 2022-11-17 19:40
     * @param xxlJobInfo xxlJobInfo
     */
    void update(XxlJobInfo xxlJobInfo);

    /**
     * remove job
     * @author Victor.Xiao
     * @since 2022-11-17 19:40
     * @param id id
    */
    void remove(int id);
    /**
     * remove job
     * @author Victor.Xiao
     * @since 2022-11-17 19:40
     * @param ids ids
     */
    void remove(Collection<Integer> ids);

    /**
     * 根据条件删除
     * @author Victor.Xiao
     * @since 2022-11-22 17:45
     * @param query query
    */
    void remove(XxlJobPageReq query);

    /**
     * start job
     * @author Victor.Xiao
     * @since 2022-11-22 17:25
     * @param id id
    */
    void start(int id);

    /**
     * stop job
     * @author Victor.Xiao
     * @since 2022-11-22 17:25
     * @param id id
    */
    void stop(int id);

    /**
     * 出发一次任务
     * @author Victor.Xiao
     * @since 2022-11-22 17:26
     * @param id id
     * @param executorParam executorParam
     * @param addressList addressList
    */
    void triggerJob(int id, String executorParam, String addressList);

    /**
     * 下一次触发时间
     * @author Victor.Xiao
     * @since 2022-11-22 17:26
     * @param scheduleType scheduleType
     * @param scheduleConf scheduleConf
     * @return java.util.List<java.lang.String>
    */
    List<String> nextTriggerTime(String scheduleType, String scheduleConf);


    /**
     * 查询当前定时job的groupId
     * @author Victor.Xiao
     * @since 2023-05-22 10:50
     * @return java.lang.Integer
     */
    XxlGroupInfo selectJobGroupId();
}
